package com.hanter.android.radui.mvvm

import android.os.Bundle
import android.view.View
import com.hanter.android.radui.R
import com.hanter.android.radui.mvp.TitleBarHelper

abstract class MvvmTitleBarFragment : BaseMvvmFragment() {

    lateinit var titleBarHelper: TitleBarHelper

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initTitleBar()
    }

    protected open fun initTitleBar() {
        titleBarHelper = TitleBarHelper(contentView!!)
        titleBarHelper.initTitleBar()
        titleBarHelper.leftBarButton.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {

            R.id.leftBarButton -> {
                activity?.onBackPressed()
            }

            else -> super.onClick(v)
        }
    }

}
